package vy.org.app.page.lookup.delivery;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.vy.dal.dao.lookup.VyLookupDeliveryModeDO;

public class DeliveryModeHelper {

	public static SimpleDateFormat _DATE_FMT = new SimpleDateFormat("MM/dd/yyyy");
	
	public static MntnDeliveryModeForm fillPatrikaForm(VyLookupDeliveryModeDO dto) {
		MntnDeliveryModeForm form = new MntnDeliveryModeForm();
		form.setLastUpdatedBy(dto.getLastUpdtBy());
		form.setLastUpdatedOn(_DATE_FMT.format(dto.getLastUpdtOn()));
		form.setDeliveryModeCode(dto.getDeliveryModeCode());
		form.setDeliveryModeName(dto.getDeliveryModeName());
		form.setIsActive(dto.getIsActive().toString());
		
		return form;
	}
	
	public static VyLookupDeliveryModeDO fillPatrikaForm(MntnDeliveryModeForm form) throws Exception {
		VyLookupDeliveryModeDO dto = new VyLookupDeliveryModeDO();
		
		dto.setLastUpdtBy(form.getLastUpdatedBy());
		dto.setLastUpdtOn(new Date());
		if(form.getDeliveryModeCode() != null && !"".equals(form.getDeliveryModeCode()))
			dto.setDeliveryModeCode(form.getDeliveryModeCode());
		dto.setDeliveryModeName(form.getDeliveryModeName());
		dto.setIsActive(Boolean.parseBoolean(form.getIsActive()));
		
		return dto;
	}	
}
